<template>
  <div class="recommend">
    <Scroll class="recommend-content" :data="discList">
      <div>
        <Swiper :swiperSlides="swiperSlideImages" ></Swiper>
        <div class="recommend-list">
          <h2 class="list-title">热门歌单推荐</h2>
          <ul class="discList">
            <li v-for="(item,index) in discList" :key="index" class="item">
              <div class="icon">
                <img v-lazy="item.imgurl" alt width="60" height="60">
              </div>
              <div class="text">
                <h3 class="name" v-html="item.creator.name"></h3>
                <p class="desc" v-html="item.dissname"></p>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="loading-container" v-if="!discList.length">
        <Loading></Loading>
      </div>
    </Scroll>
  </div>
</template>

<script>
import { getRecommend, getDiscList } from "../../api/recommend.js";
import Scroll from "../base/scroll/scroll.vue";
import { ERR_OK } from "../../api/config.js";
import Swiper from "../base/swiper/swiper.vue";
import Loading from "@/components/base/loading/loading.vue";
export default {
  data() {
    return {
      swiperSlideImages: [],
      discList: []
    };
  },
  created() {
    this._getRecommend();
    this._getDiscList();
  },
  methods: {
    _getRecommend() {
      getRecommend().then(res => {
        if (res.code === ERR_OK) {
          this.swiperSlideImages = res.data.slider;
        }
      });
    },
    _getDiscList() {
      getDiscList().then(res => {
        this.discList = res.data.list;
      });
    }
  },
  components: {
    Swiper,
    Scroll,
    Loading
  }
};
</script>

<style lang="stylus" scoped>
@import '../../common/stylus/variable';
// 设置swiper组件外部容器高度
.recommend 
  position: fixed;
  width: 100%;
  top: 88px;
  bottom: 0;
  .recommend-content 
    height: 100%;
    overflow: hidden;
    .swiper-slide 
      height: 140px;
    .recommend-list 
      .list-title 
        height: 55px;
        line-height: 55px;
        text-align: center;
        padding: 0 10px 10px 10px;
        font-size: $font-size-medium;
        color: $color-theme;
      .discList 
        width: 90%;
        margin: 0 auto;
        .item 
          display: flex;
          align-items: center;
          height: 60px;
          padding: 0 10px 10px 0;
          .icon 
            width: 60px;
            padding-right: 20px;
          .text 
            height: 40px;
            .name 
              color: #fff;
              padding-bottom: 10px;
              font-size: $font-size-small-s;
            .desc 
              color: $color-text-d;
  .loading-container
    position absolute 
    top 50%
    left 50%

    padding 25px
    margin-left -40px
    border-radius 5px
    background rgba(255,255,255,.3)
</style>
